<?php
namespace app\index\service;

use app\index\model\AcckuanModel;
use app\index\model\AccountListModel;
use app\index\model\FlowLogModel;
use app\index\model\LogListModel;
use app\index\model\ShouQiListModel;
use app\index\model\ShouTouListModel;
use app\index\model\ShouXiangListModel;
use app\index\model\ZhiDaybaoListModel;
use app\index\model\ZhiDayfuListModel;
use app\index\model\ZhiEnbaoListModel;
use app\index\model\ZhiTouListModel;
use app\index\model\ZhiXiangListModel;
use think\Db;

class KuanService extends CommonService
{
    public function get_acckuan_paystate(){
        return [
            0 => '未支付',
            1 => '部分支付',
            2 => '全部支付',
        ];
    }
    public function get_acckuan_paystate_name($paystate=0){
        $arr = $this->get_acckuan_paystate();
        $str = isset($arr[$paystate]) ? $arr[$paystate] : '';
        return $str;
    }


    public function get_acckuan_modtype($type=1){
        if($type == 1){
            return [
                1 => '投标费收取',
                2 => '项目收款',
                3 => '备用金还款',
                4 => '其他收款',
                5 => '保证金收取',
                6 => '保证金退回',

            ];
        }elseif($type == 2){
            return [
                21 => '投标费支付',
                22 => '项目付款',
                23 => '项目费用报销',
                24 => '进项退税',
                25 => '联营结算',
                26 => '备用金借支',
                27 => '日常费用报销',
                28 => '日常付款',
                29 => '保证金缴纳',
                30 => '保证金返还',

            ];
        }else{
            return [
                1 => '投标费收取',
                2 => '项目收款',
                3 => '备用金还款',
                4 => '其他收款',
                5 => '保证金收取',
                6 => '保证金退回',

                21 => '投标费支付',
                22 => '项目付款',
                23 => '项目费用报销',
                24 => '进项退税',
                25 => '联营结算',
                26 => '备用金借支',
                27 => '日常费用报销',
                28 => '日常付款',
                29 => '保证金缴纳',
                30 => '保证金返还',
            ];
        }
    }
    public function get_acckuan_modtype_name($modtype=0){
        $arr = $this->get_acckuan_modtype(3);
        $str = isset($arr[$modtype]) ? $arr[$modtype] : '';
        return $str;
    }




    public function shou_tou($bill, $minfo){
        $exist = AcckuanModel::where(['comid'=>$this->userinfo['comid'],'deleted_user'=>0,'billid'=>$bill['id']])->find();
        if($exist){return true;}
        $modtype = 1;

        $ins = [];
        $ins['modtype'] = $modtype;
        $ins['comid'] = $this->userinfo['comid'];
        $ins['billid'] = $bill['id'];
        $ins['mid'] = $minfo['id'];
        $ins['enginid'] = $minfo['enginid'];
        $ins['number'] = $minfo['number'];
        $ins['feilei'] = $minfo['feilei'];
        $ins['feitype'] = ShouTouListModel::where(['shouid'=>$minfo['id']])->value('feitype');
        $ins['zhai'] = $minfo['zhai'];
        $ins['money'] = $minfo['money'];
        $ins['duier'] = $minfo['duier'];
        $ins['dt'] = $minfo['dt'];
        $ins['baner'] = $minfo['baner'];
        $ins['incdaotype'] = (new OptService())->get_base_showname('cai_income_incdaotype', $minfo['incdaotype']);
        $ins['accid'] = $minfo['accid'];
        $ins['explain'] = $minfo['explain'];
        $ins['created_user'] = $minfo['created_user'];
        $ins['created_at'] = date('Y-m-d H:i:s');
        $kuanid = AcckuanModel::insertGetId($ins);

        $acclist = [];
        $acclist['comid'] = $this->userinfo['comid'];
        $acclist['kuanid'] = $kuanid;
        $acclist['modtype'] = $modtype;
        $acclist['jiaonum'] = (new FinanceService())->create_account_list_jiaonum_shou();
        $acclist['money'] = $ins['money'];
        $acclist['accid'] = $ins['accid'];
        $acclist['dt'] = $ins['dt'];
        $acclist['baner'] = $bill['flowuser'];
        $acclist['created_user'] = $ins['created_user'];
        $acclist['created_at'] = $ins['created_at'];

        $acclistid = AccountListModel::insertGetId($acclist);
        (new OptService())->add_flow_log(FlowLogModel::SET_ADD, 'account_list', $acclistid);
        (new OptService())->add_log_list(FlowLogModel::SET_ADD, 'account_list', $acclistid, '交易记录');
        return true;
    }
    public function shou_xiang($bill, $minfo){
        $exist = AcckuanModel::where(['comid'=>$this->userinfo['comid'],'deleted_user'=>0,'billid'=>$bill['id']])->find();
        if($exist){return true;}
        $modtype = 2;

        $ins = [];
        $ins['modtype'] = $modtype;
        $ins['comid'] = $this->userinfo['comid'];
        $ins['billid'] = $bill['id'];
        $ins['mid'] = $minfo['id'];
        $ins['enginid'] = $minfo['enginid'];
        $ins['number'] = $minfo['number'];
        $ins['feilei'] = $minfo['feilei'];
        $ins['feitype'] = ShouXiangListModel::where(['shouid'=>$minfo['id']])->value('feitype');
        $ins['zhai'] = $minfo['zhai'];
        $ins['money'] = $minfo['money'];
        $ins['duier'] = $minfo['duier'];
        $ins['dt'] = $minfo['dt'];
        $ins['baner'] = $minfo['baner'];
        $ins['incdaotype'] = (new OptService())->get_base_showname('cai_income_incdaotype', $minfo['incdaotype']);
        $ins['accid'] = $minfo['accid'];
        $ins['explain'] = $minfo['explain'];
        $ins['created_user'] = $minfo['created_user'];
        $ins['created_at'] = date('Y-m-d H:i:s');
        $kuanid = AcckuanModel::insertGetId($ins);

        $acclist = [];
        $acclist['comid'] = $this->userinfo['comid'];
        $acclist['kuanid'] = $kuanid;
        $acclist['modtype'] = $modtype;
        $acclist['jiaonum'] = (new FinanceService())->create_account_list_jiaonum_shou();
        $acclist['money'] = $ins['money'];
        $acclist['accid'] = $ins['accid'];
        $acclist['dt'] = $ins['dt'];
        $acclist['baner'] = $bill['flowuser'];
        $acclist['created_user'] = $ins['created_user'];
        $acclist['created_at'] = $ins['created_at'];
        $acclistid = AccountListModel::insertGetId($acclist);
        (new OptService())->add_flow_log(FlowLogModel::SET_ADD, 'account_list', $acclistid);
        (new OptService())->add_log_list(FlowLogModel::SET_ADD, 'account_list', $acclistid, '交易记录');

        return true;
    }
    public function shou_huan($bill, $minfo){
        $exist = AcckuanModel::where(['comid'=>$this->userinfo['comid'],'deleted_user'=>0,'billid'=>$bill['id']])->find();
        if($exist){return true;}
        $modtype = 3;

        $ins = [];
        $ins['modtype'] = $modtype;
        $ins['comid'] = $this->userinfo['comid'];
        $ins['billid'] = $bill['id'];
        $ins['mid'] = $minfo['id'];
        $ins['number'] = $minfo['number'];
        $ins['feilei'] = $minfo['feilei'];
        $ins['feitype'] = $minfo['feitype'];
        $ins['zhai'] = $minfo['zhai'];
        $ins['money'] = $minfo['money'];
        $ins['duier'] = $minfo['duier'];
        $ins['dt'] = $minfo['dt'];
        $ins['baner'] = $minfo['duier'];
        $ins['incdaotype'] = (new OptService())->get_base_showname('cai_income_incdaotype', $minfo['incdaotype']);
        $ins['accid'] = $minfo['accid'];
        $ins['explain'] = $minfo['explain'];
        $ins['created_user'] = $minfo['created_user'];
        $ins['created_at'] = date('Y-m-d H:i:s');
        $kuanid = AcckuanModel::insertGetId($ins);

        $acclist = [];
        $acclist['comid'] = $this->userinfo['comid'];
        $acclist['kuanid'] = $kuanid;
        $acclist['modtype'] = $modtype;
        $acclist['jiaonum'] = (new FinanceService())->create_account_list_jiaonum_shou();
        $acclist['money'] = $ins['money'];
        $acclist['accid'] = $ins['accid'];
        $acclist['dt'] = $ins['dt'];
        $acclist['baner'] = $bill['flowuser'];
        $acclist['created_user'] = $ins['created_user'];
        $acclist['created_at'] = $ins['created_at'];
        $acclistid = AccountListModel::insertGetId($acclist);
        (new OptService())->add_flow_log(FlowLogModel::SET_ADD, 'account_list', $acclistid);
        (new OptService())->add_log_list(FlowLogModel::SET_ADD, 'account_list', $acclistid, '交易记录');

        return true;
    }
    public function shou_qi($bill, $minfo){
        $exist = AcckuanModel::where(['comid'=>$this->userinfo['comid'],'deleted_user'=>0,'billid'=>$bill['id']])->find();
        if($exist){return true;}
        $modtype = 4;

        $ins = [];
        $ins['modtype'] = $modtype;
        $ins['comid'] = $this->userinfo['comid'];
        $ins['billid'] = $bill['id'];
        $ins['mid'] = $minfo['id'];
        $ins['number'] = $minfo['number'];
        $ins['feilei'] = $minfo['feilei'];
        $ins['feitype'] = ShouQiListModel::where(['shouid'=>$minfo['id']])->value('feitype');
        $ins['zhai'] = $minfo['zhai'];
        $ins['money'] = $minfo['money'];
        $ins['duier'] = $minfo['duier'];
        $ins['dt'] = $minfo['dt'];
        $ins['baner'] = $minfo['baner'];
        $ins['incdaotype'] = (new OptService())->get_base_showname('cai_income_incdaotype', $minfo['incdaotype']);
        $ins['accid'] = $minfo['accid'];
        $ins['explain'] = $minfo['explain'];
        $ins['created_user'] = $minfo['created_user'];
        $ins['created_at'] = date('Y-m-d H:i:s');
        $kuanid = AcckuanModel::insertGetId($ins);

        $acclist = [];
        $acclist['comid'] = $this->userinfo['comid'];
        $acclist['kuanid'] = $kuanid;
        $acclist['modtype'] = $modtype;
        $acclist['jiaonum'] = (new FinanceService())->create_account_list_jiaonum_shou();
        $acclist['money'] = $ins['money'];
        $acclist['accid'] = $ins['accid'];
        $acclist['dt'] = $ins['dt'];
        $acclist['baner'] = $bill['flowuser'];
        $acclist['created_user'] = $ins['created_user'];
        $acclist['created_at'] = $ins['created_at'];
        $acclistid = AccountListModel::insertGetId($acclist);
        (new OptService())->add_flow_log(FlowLogModel::SET_ADD, 'account_list', $acclistid);
        (new OptService())->add_log_list(FlowLogModel::SET_ADD, 'account_list', $acclistid, '交易记录');

        return true;
    }
    public function bond_shou($bill, $minfo){
        $exist = AcckuanModel::where(['comid'=>$this->userinfo['comid'],'deleted_user'=>0,'billid'=>$bill['id']])->find();
        if($exist){return true;}
        $modtype = 5;

        $ins = [];
        $ins['modtype'] = $modtype;
        $ins['comid'] = $this->userinfo['comid'];
        $ins['billid'] = $bill['id'];
        $ins['mid'] = $minfo['id'];
        $ins['enginid'] = $minfo['enginid'];
        $ins['number'] = $minfo['number'];
        $ins['feilei'] = $minfo['feilei'];
        $ins['feitype'] = $minfo['feitype'];
        $ins['zhai'] = $minfo['zhai'];
        $ins['money'] = $minfo['money'];
        $ins['duier'] = $minfo['duier'];
        $ins['dt'] = $minfo['dt'];
        $ins['baner'] = $minfo['baner'];
        $ins['incdaotype'] = (new OptService())->get_base_showname('cai_income_incdaotype', $minfo['incdaotype']);
        $ins['accid'] = $minfo['accid'];
        $ins['explain'] = $minfo['explain'];
        $ins['created_user'] = $minfo['created_user'];
        $ins['created_at'] = date('Y-m-d H:i:s');
        $kuanid = AcckuanModel::insertGetId($ins);

        $acclist = [];
        $acclist['comid'] = $this->userinfo['comid'];
        $acclist['kuanid'] = $kuanid;
        $acclist['modtype'] = $modtype;
        $acclist['jiaonum'] = (new FinanceService())->create_account_list_jiaonum_shou();
        $acclist['money'] = $ins['money'];
        $acclist['accid'] = $ins['accid'];
        $acclist['dt'] = $ins['dt'];
        $acclist['baner'] = $bill['flowuser'];
        $acclist['created_user'] = $ins['created_user'];
        $acclist['created_at'] = $ins['created_at'];
        $acclistid = AccountListModel::insertGetId($acclist);
        (new OptService())->add_flow_log(FlowLogModel::SET_ADD, 'account_list', $acclistid);
        (new OptService())->add_log_list(FlowLogModel::SET_ADD, 'account_list', $acclistid, '交易记录');

        return true;
    }
    public function bond_tui($bill, $minfo){
        $exist = AcckuanModel::where(['comid'=>$this->userinfo['comid'],'deleted_user'=>0,'billid'=>$bill['id']])->find();
        if($exist){return true;}
        $modtype = 6;

        $ins = [];
        $ins['modtype'] = $modtype;
        $ins['comid'] = $this->userinfo['comid'];
        $ins['billid'] = $bill['id'];
        $ins['mid'] = $minfo['id'];
        $ins['enginid'] = $minfo['enginid'];
        $ins['number'] = $minfo['number'];
        $ins['feilei'] = $minfo['feilei'];
        $ins['feitype'] = $minfo['feitype'];
        $ins['zhai'] = $minfo['zhai'];
        $ins['money'] = $minfo['money'];
        $ins['duier'] = $minfo['duier'];
        $ins['dt'] = $minfo['dt'];
        $ins['baner'] = $minfo['baner'];
        $ins['incdaotype'] = (new OptService())->get_base_showname('cai_income_incdaotype', $minfo['incdaotype']);
        $ins['accid'] = $minfo['accid'];
        $ins['explain'] = $minfo['explain'];
        $ins['created_user'] = $minfo['created_user'];
        $ins['created_at'] = date('Y-m-d H:i:s');
        $kuanid = AcckuanModel::insertGetId($ins);

        $acclist = [];
        $acclist['comid'] = $this->userinfo['comid'];
        $acclist['kuanid'] = $kuanid;
        $acclist['modtype'] = $modtype;
        $acclist['jiaonum'] = (new FinanceService())->create_account_list_jiaonum_shou();
        $acclist['money'] = $ins['money'];
        $acclist['accid'] = $ins['accid'];
        $acclist['dt'] = $ins['dt'];
        $acclist['baner'] = $bill['flowuser'];
        $acclist['created_user'] = $ins['created_user'];
        $acclist['created_at'] = $ins['created_at'];
        $acclistid = AccountListModel::insertGetId($acclist);
        (new OptService())->add_flow_log(FlowLogModel::SET_ADD, 'account_list', $acclistid);
        (new OptService())->add_log_list(FlowLogModel::SET_ADD, 'account_list', $acclistid, '交易记录');

        return true;
    }


    public function zhi_tou($bill, $minfo){
        $exist = AcckuanModel::where(['comid'=>$this->userinfo['comid'],'deleted_user'=>0,'billid'=>$bill['id']])->find();
        if($exist){return true;}
        $modtype = 21;

        $ins = [];
        $ins['modtype'] = $modtype;
        $ins['comid'] = $this->userinfo['comid'];
        $ins['billid'] = $bill['id'];
        $ins['mid'] = $minfo['id'];
        $ins['enginid'] = $minfo['enginid'];
        $ins['number'] = $minfo['number'];
        $ins['feilei'] = $minfo['feilei'];
        $ins['feitype'] = ZhiTouListModel::where(['zhiid'=>$minfo['id']])->value('feitype');
        $ins['zhai'] = $minfo['zhai'];
        $ins['money'] = $minfo['money'];
        $ins['duier'] = $minfo['duier'];
        $ins['dt'] = date("Y-m-d", strtotime($minfo['created_at']));
        $ins['baner'] = $minfo['flowuser'];
        $ins['incdaotype'] = (new OptService())->get_base_showname('cai_income_incdaotype', $minfo['incdaotype']);
        $ins['banknum'] = $minfo['banknum'];
        $ins['bankname'] = $minfo['bankname'];
        $ins['explain'] = $minfo['explain'];
        $ins['created_user'] = $minfo['created_user'];
        $ins['created_at'] = date('Y-m-d H:i:s');
        $kuanid = AcckuanModel::insertGetId($ins);

        return true;
    }
    public function zhi_xiang($bill, $minfo){
        $exist = AcckuanModel::where(['comid'=>$this->userinfo['comid'],'deleted_user'=>0,'billid'=>$bill['id']])->find();
        if($exist){return true;}
        $modtype = 22;

        $ins = [];
        $ins['modtype'] = $modtype;
        $ins['comid'] = $this->userinfo['comid'];
        $ins['billid'] = $bill['id'];
        $ins['mid'] = $minfo['id'];
        $ins['enginid'] = $minfo['enginid'];
        $ins['number'] = $minfo['number'];
        $ins['feilei'] = $minfo['feilei'];
        $ins['feitype'] = ZhiXiangListModel::where(['zhiid'=>$minfo['id']])->value('feitype');
        $ins['zhai'] = $minfo['zhai'];
        $ins['money'] = $minfo['money'];
        $ins['duier'] = $minfo['duier'];
        $ins['dt'] = date("Y-m-d", strtotime($minfo['created_at']));
        $ins['baner'] = $minfo['flowuser'];
        $ins['incdaotype'] = (new OptService())->get_base_showname('cai_income_incdaotype', $minfo['incdaotype']);
        $ins['banknum'] = $minfo['banknum'];
        $ins['bankname'] = $minfo['bankname'];
        $ins['explain'] = $minfo['explain'];
        $ins['created_user'] = $minfo['created_user'];
        $ins['created_at'] = date('Y-m-d H:i:s');
        $kuanid = AcckuanModel::insertGetId($ins);

        return true;
    }
    public function zhi_enbao($bill, $minfo){
        $exist = AcckuanModel::where(['comid'=>$this->userinfo['comid'],'deleted_user'=>0,'billid'=>$bill['id']])->find();
        if($exist){return true;}
        $modtype = 23;

        $ins = [];
        $ins['modtype'] = $modtype;
        $ins['comid'] = $this->userinfo['comid'];
        $ins['billid'] = $bill['id'];
        $ins['mid'] = $minfo['id'];
        $ins['enginid'] = $minfo['enginid'];
        $ins['number'] = $minfo['number'];
        $ins['feilei'] = $minfo['feilei'];
        $ins['feitype'] = ZhiEnbaoListModel::where(['zhiid'=>$minfo['id']])->value('feitype');
        $ins['zhai'] = $minfo['zhai'];
        $ins['money'] = $minfo['shifee'];
        $ins['duier'] = $minfo['duier'];
        $ins['dt'] = date("Y-m-d", strtotime($minfo['created_at']));
        $ins['baner'] = $minfo['flowuser'];
        $ins['incdaotype'] = (new OptService())->get_base_showname('cai_income_incdaotype', $minfo['incdaotype']);
        $ins['banknum'] = $minfo['banknum'];
        $ins['bankname'] = $minfo['bankname'];
        $ins['explain'] = $minfo['explain'];
        $ins['created_user'] = $minfo['created_user'];
        $ins['created_at'] = date('Y-m-d H:i:s');
        $kuanid = AcckuanModel::insertGetId($ins);

        return true;
    }
    public function zhi_jintui($bill, $minfo){
        $exist = AcckuanModel::where(['comid'=>$this->userinfo['comid'],'deleted_user'=>0,'billid'=>$bill['id']])->find();
        if($exist){return true;}
        $modtype = 24;

        $ins = [];
        $ins['modtype'] = $modtype;
        $ins['comid'] = $this->userinfo['comid'];
        $ins['billid'] = $bill['id'];
        $ins['mid'] = $minfo['id'];
        $ins['enginid'] = $minfo['enginid'];
        $ins['number'] = $minfo['number'];
        $ins['feilei'] = $minfo['feilei'];
        $ins['feitype'] = $minfo['feitype'];
        $ins['zhai'] = $minfo['zhai'];
        $ins['money'] = $minfo['money'];
        $ins['duier'] = $minfo['duier'];
        $ins['dt'] = date("Y-m-d", strtotime($minfo['created_at']));
        $ins['baner'] = $minfo['flowuser'];
        $ins['incdaotype'] = (new OptService())->get_base_showname('cai_income_incdaotype', $minfo['incdaotype']);
        $ins['banknum'] = $minfo['banknum'];
        $ins['bankname'] = $minfo['bankname'];
        $ins['explain'] = $minfo['explain'];
        $ins['created_user'] = $minfo['created_user'];
        $ins['created_at'] = date('Y-m-d H:i:s');
        $kuanid = AcckuanModel::insertGetId($ins);

        return true;
    }
    public function zhi_lianjie($bill, $minfo){
        $exist = AcckuanModel::where(['comid'=>$this->userinfo['comid'],'deleted_user'=>0,'billid'=>$bill['id']])->find();
        if($exist){return true;}
        $modtype = 25;

        $ins = [];
        $ins['modtype'] = $modtype;
        $ins['comid'] = $this->userinfo['comid'];
        $ins['billid'] = $bill['id'];
        $ins['mid'] = $minfo['id'];
        $ins['enginid'] = $minfo['enginid'];
        $ins['number'] = $minfo['number'];
        $ins['feilei'] = $minfo['feilei'];
        $ins['feitype'] = $minfo['feitype'];
        $ins['zhai'] = $minfo['zhai'];
        $ins['money'] = $minfo['money'];
        $ins['duier'] = $minfo['duier'];
        $ins['dt'] = date("Y-m-d", strtotime($minfo['created_at']));
        $ins['baner'] = $minfo['flowuser'];
        $ins['incdaotype'] = (new OptService())->get_base_showname('cai_income_incdaotype', $minfo['incdaotype']);
        $ins['banknum'] = $minfo['banknum'];
        $ins['bankname'] = $minfo['bankname'];
        $ins['explain'] = $minfo['explain'];
        $ins['created_user'] = $minfo['created_user'];
        $ins['created_at'] = date('Y-m-d H:i:s');
        $kuanid = AcckuanModel::insertGetId($ins);

        return true;
    }
    public function zhi_jie($bill, $minfo){
        $exist = AcckuanModel::where(['comid'=>$this->userinfo['comid'],'deleted_user'=>0,'billid'=>$bill['id']])->find();
        if($exist){return true;}
        $modtype = 26;

        $ins = [];
        $ins['modtype'] = $modtype;
        $ins['comid'] = $this->userinfo['comid'];
        $ins['billid'] = $bill['id'];
        $ins['mid'] = $minfo['id'];
        $ins['enginid'] = $minfo['enginid'];
        $ins['number'] = $minfo['number'];
        $ins['feilei'] = $minfo['feilei'];
        $ins['feitype'] = $minfo['feitype'];
        $ins['zhai'] = $minfo['zhai'];
        $ins['money'] = $minfo['money'];
        $ins['duier'] = $minfo['duier'];
        $ins['dt'] = date("Y-m-d", strtotime($minfo['created_at']));
        $ins['baner'] = $minfo['flowuser'];
        $ins['incdaotype'] = (new OptService())->get_base_showname('cai_income_incdaotype', $minfo['incdaotype']);
        $ins['banknum'] = $minfo['banknum'];
        $ins['bankname'] = $minfo['bankname'];
        $ins['explain'] = $minfo['explain'];
        $ins['created_user'] = $minfo['created_user'];
        $ins['created_at'] = date('Y-m-d H:i:s');
        $kuanid = AcckuanModel::insertGetId($ins);

        return true;
    }
    public function zhi_daybao($bill, $minfo){
        $exist = AcckuanModel::where(['comid'=>$this->userinfo['comid'],'deleted_user'=>0,'billid'=>$bill['id']])->find();
        if($exist){return true;}
        $modtype = 27;

        $ins = [];
        $ins['modtype'] = $modtype;
        $ins['comid'] = $this->userinfo['comid'];
        $ins['billid'] = $bill['id'];
        $ins['mid'] = $minfo['id'];
        $ins['number'] = $minfo['number'];
        $ins['feilei'] = $minfo['feilei'];
        $ins['feitype'] = ZhiDaybaoListModel::where(['zhiid'=>$minfo['id']])->value('feitype');
        $ins['zhai'] = $minfo['zhai'];
        $ins['money'] = $minfo['shifee'];
        $ins['duier'] = $minfo['duier'];
        $ins['dt'] = date("Y-m-d", strtotime($minfo['created_at']));
        $ins['baner'] = $minfo['flowuser'];
        $ins['incdaotype'] = (new OptService())->get_base_showname('cai_income_incdaotype', $minfo['incdaotype']);
        $ins['banknum'] = $minfo['banknum'];
        $ins['bankname'] = $minfo['bankname'];
        $ins['explain'] = $minfo['explain'];
        $ins['created_user'] = $minfo['created_user'];
        $ins['created_at'] = date('Y-m-d H:i:s');
        $kuanid = AcckuanModel::insertGetId($ins);

        return true;
    }
    public function zhi_dayfu($bill, $minfo){
        $exist = AcckuanModel::where(['comid'=>$this->userinfo['comid'],'deleted_user'=>0,'billid'=>$bill['id']])->find();
        if($exist){return true;}
        $modtype = 28;

        $ins = [];
        $ins['modtype'] = $modtype;
        $ins['comid'] = $this->userinfo['comid'];
        $ins['billid'] = $bill['id'];
        $ins['mid'] = $minfo['id'];
        $ins['number'] = $minfo['number'];
        $ins['feilei'] = $minfo['feilei'];
        $ins['feitype'] = ZhiDayfuListModel::where(['zhiid'=>$minfo['id']])->value('feitype');
        $ins['zhai'] = $minfo['zhai'];
        $ins['money'] = $minfo['money'];
        $ins['duier'] = $minfo['duier'];
        $ins['dt'] = date("Y-m-d", strtotime($minfo['created_at']));
        $ins['baner'] = $minfo['flowuser'];
        $ins['incdaotype'] = (new OptService())->get_base_showname('cai_income_incdaotype', $minfo['incdaotype']);
        $ins['banknum'] = $minfo['banknum'];
        $ins['bankname'] = $minfo['bankname'];
        $ins['explain'] = $minfo['explain'];
        $ins['created_user'] = $minfo['created_user'];
        $ins['created_at'] = date('Y-m-d H:i:s');
        $kuanid = AcckuanModel::insertGetId($ins);

        return true;
    }
    public function bond_jiao($bill, $minfo){
        $exist = AcckuanModel::where(['comid'=>$this->userinfo['comid'],'deleted_user'=>0,'billid'=>$bill['id']])->find();
        if($exist){return true;}
        $modtype = 29;

        $ins = [];
        $ins['modtype'] = $modtype;
        $ins['comid'] = $this->userinfo['comid'];
        $ins['billid'] = $bill['id'];
        $ins['mid'] = $minfo['id'];
        $ins['enginid'] = $minfo['enginid'];
        $ins['number'] = $minfo['number'];
        $ins['feilei'] = $minfo['feilei'];
        $ins['feitype'] = $minfo['feitype'];
        $ins['zhai'] = $minfo['zhai'];
        $ins['money'] = $minfo['money'];
        $ins['duier'] = $minfo['duier'];
        $ins['dt'] = date("Y-m-d", strtotime($minfo['created_at']));
        $ins['baner'] = $minfo['flowuser'];
        $ins['incdaotype'] = (new OptService())->get_base_showname('cai_income_incdaotype', $minfo['incdaotype']);
        $ins['banknum'] = $minfo['banknum'];
        $ins['bankname'] = $minfo['bankname'];
        $ins['explain'] = $minfo['explain'];
        $ins['created_user'] = $minfo['created_user'];
        $ins['created_at'] = date('Y-m-d H:i:s');
        $kuanid = AcckuanModel::insertGetId($ins);

        return true;
    }
    public function bond_fan($bill, $minfo){
        $exist = AcckuanModel::where(['comid'=>$this->userinfo['comid'],'deleted_user'=>0,'billid'=>$bill['id']])->find();
        if($exist){return true;}
        $modtype = 30;

        $ins = [];
        $ins['modtype'] = $modtype;
        $ins['comid'] = $this->userinfo['comid'];
        $ins['billid'] = $bill['id'];
        $ins['mid'] = $minfo['id'];
        $ins['enginid'] = $minfo['enginid'];
        $ins['number'] = $minfo['number'];
        $ins['feilei'] = $minfo['feilei'];
        $ins['feitype'] = $minfo['feitype'];
        $ins['zhai'] = $minfo['zhai'];
        $ins['money'] = $minfo['money'];
        $ins['duier'] = $minfo['duier'];
        $ins['dt'] = date("Y-m-d", strtotime($minfo['created_at']));
        $ins['baner'] = $minfo['flowuser'];
        $ins['incdaotype'] = (new OptService())->get_base_showname('cai_income_incdaotype', $minfo['incdaotype']);
        $ins['banknum'] = $minfo['banknum'];
        $ins['bankname'] = $minfo['bankname'];
        $ins['explain'] = $minfo['explain'];
        $ins['created_user'] = $minfo['created_user'];
        $ins['created_at'] = date('Y-m-d H:i:s');
        $kuanid = AcckuanModel::insertGetId($ins);

        return true;
    }


}
